﻿/*
 * FileName:    ScriptInitializer 
 * Description:
 * 用于初始化脚本文件，使用前请先修改Unity的脚本模板
 * 文件请放置于Editor文件夹下
*/
using System.IO;
using System.Text.RegularExpressions;

namespace UnityEditor
{
	public class ScriptInitializer : UnityEditor.AssetModificationProcessor
	{
		public static void OnWillCreateAsset(string path)
		{
			path = path.Replace(".meta", "");
			if (path.ToLower().EndsWith(".cs") || path.ToLower().EndsWith(".lua"))
			{
				string text = File.ReadAllText(path);
				text = Regex.Replace(text, "#AUTHORNAME#", "songzuheng");
				text = Regex.Replace(text, "#CREATETIME#", System.DateTime.Now.ToString());
				text = Regex.Replace(text, "#DESCRIPTION#", "有bug可以找我改啊");

				File.WriteAllText(path, text);
			}
		}
	}
}